/* rcshhdr.i - Include file for validation routine used by shipper header     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.4.1.2 $                                                       */
/*V8:ConvertMode=NoConvert                                                    */
/* REVISION: 8.6          CREATED: 07/22/96   BY: *K003* Vinay Nayak-Sujir    */
/* REVISION: 8.6    LAST MODIFIED: 03/26/97   BY: *K093* Vinay Nayak-Sujir    */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan           */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown           */
/* $Revision: 1.4.1.2 $   BY: Jean Miller        DATE: 04/09/02  ECO: *P058*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

PROCEDURE validate_shipto:
   define input  parameter shipto like abs_shipto no-undo.
   define output parameter err as logical no-undo.

   define variable addr like ad_addr no-undo.

   err = false.

   find first ls_mstr where ls_addr = shipto
      and (ls_type = "customer"
        or ls_type = "ship-to"
        or ls_type = "dock")
   no-lock no-error.

   find ad_mstr where ad_addr = shipto no-lock no-error.

   if not available ls_mstr
      or not available ad_mstr
   then do:
      {pxmsg.i &MSGNUM=8129 &ERRORLEVEL=3}
      /* NOT A VALID CUSTOMER OR SHIP-TO */
      err = true.
      bell.
      leave.
   end.

   find cm_mstr where cm_addr = shipto no-lock no-error.

   do while not available cm_mstr and ad_ref > "":
      addr = ad_ref.
      find ad_mstr where ad_addr = addr no-lock.
      find cm_mstr where cm_addr = ad_addr no-lock no-error.
   end.

   if not available cm_mstr then do:
      pause 5.
      {pxmsg.i &MSGNUM=8129 &ERRORLEVEL=3}
      /* NOT A VALID CUSTOMER OR SHIP-TO */
      err = true.
      bell.
      leave.
   end.

   if cm_cr_hold then do:
      {pxmsg.i &MSGNUM=614 &ERRORLEVEL=2}
      /* CUSTOMER ON CREDIT HOLD */
   end.

END PROCEDURE.

{gpnbrgen.i}
